﻿@{
    ViewBag.Title = "Felhasználó könyvtárai";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@model ELTE.SEM.Data.ViewModels.UserFoldersViewModel
<div user-folders-main-container>
    <script type="text/javascript" src="/Scripts/Page/Account/UserFoldersManagement.js"></script>
    <div id="user-folder-filter-container">
        <div id="user-folder-filter">
            <input type="text" id="folder-filter-query" />
            <button type="button" id="btn-filter-folders">Szűrés</button>
        </div>
    </div>

    @using (Html.BeginForm())
    {
        <div class="save-result">
            @if (ViewBag.UserFolderManagementSuccessMessage != null)
            {
                <div class="success-message">@ViewBag.UserFolderManagementSuccessMessage</div>
            }
            else if (ViewBag.UserFolderManagementFailedMessage != null)
            {
                <div class="failed-message">@ViewBag.UserFolderManagementFailedMessage</div> 
            }
        </div>
        
        <input type="submit" value="Mentés" id="btn-folder-submit" />
        <div id="user-folders-container">
            @Html.HiddenFor(m => m.UserId)
            <div id="user-folders">

                @for (int i = 0; i < Model.FolderAccess.Count; i++)
                {
                    var folderAccess = Model.FolderAccess[i];
                    <div class="user-folder" data-path="@folderAccess.Folder.GetPath()">
                        <div class="folder-path">
                            <strong>Könyvtár elérési útja:</strong> <br />
                            <span>@folderAccess.Folder.GetPath()</span>
                        </div>
                        <div class="float-left folder-data">
                            <strong>Könyvtár neve:</strong>
                            @folderAccess.Folder.FolderName
                        </div>
                        <div class="float-left folder-data">
                            <input type="hidden" id="@String.Format("FolderAccess[{0}].Folder.Id", i)" name="@String.Format("FolderAccess[{0}].Folder.Id", i)" value="@folderAccess.Folder.Id" />
                            <input type="hidden" id="@String.Format("FolderAccess[{0}].Folder.FolderName", i)" name="@String.Format("FolderAccess[{0}].Folder.FolderName", i)" value="@folderAccess.Folder.FolderName" />

                            @if (folderAccess.HasAccess)
                            {
                                <input type="checkbox" id="@String.Format("FolderAccess[{0}].HasAccess", i)" name="@String.Format("FolderAccess[{0}].HasAccess", i)" checked="checked" />
                            }
                            else
                            {
                                <input type="checkbox" id="@String.Format("FolderAccess[{0}].HasAccess", i)" name="@String.Format("FolderAccess[{0}].HasAccess", i)" />
                            }
                            <input type="hidden" name="@String.Format("FolderAccess[{0}].HasAccess", i)" value="false" />
                            <img src="" class="invisible checkbox-image" />
                            <span>Hozzáférés engedélyezve?</span>
                            
                            
                        </div>

                    </div> 
                }
            </div>
        </div>
    }
</div>
